﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using CommonLibraries.DeviceLibrary;
using PolePositionMobileClasses.Exception;

namespace PolePositionMobile
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            Camera m_Camera = Camera.GetInstance();
            try
            {
                //Powers camera off
                m_Camera.Off(0, 0);
                //Shows homepage
                frmHomePage _Form = new frmHomePage();
                _Form.Show();
                //Starts application
                Application.Run(_Form);
            }
            catch (ExceptionNotFoundDatabase exf)
            {
                //Powers camera off
                m_Camera.Off(0, 0);
                MessageBox.Show(exf.Message, PPIConstants.K_AppName);
                Application.Exit();

            }
            catch (ExceptionIncorrectVersion exi)
            {
                //Powers camera off
                m_Camera.Off(0, 0);
                MessageBox.Show(exi.Message, PPIConstants.K_AppName);
                Application.Exit();

            }
            catch (Exception _exception)
            {
                //Powers camera off
                m_Camera.Off(0, 0);
                MessageBox.Show("An error was encountered while running the application. It is possible that the application is updating; if so, press OK and restart the application." + Environment.NewLine + "Error details are as follows:" + Environment.NewLine + _exception.Message, PPIConstants.K_AppName);
                Application.Exit();
            }
        }

    }
}